Skip to content

Feature/advanced memory - #317

Closed
CongkeChen wants to merge 87 commits into
internal_pipeline_testfrom
feature/advanced_memory
Closed

Feature/advanced memory#317
CongkeChen wants to merge 87 commits into
internal_pipeline_testfrom
feature/advanced_memory

Conversation

@CongkeChen

Copy link
Copy Markdown
Contributor

test

weimch and others added 30 commits July 30, 2026 16:39
- 修复方案:先尝试用json_repair修复,如果无法修复,工具执行时,直接返回参数错误的结果,触发Agent下次执行
- 问题:hy3要求开思考的时候,后面的对话要带上思考内容,如果不带上,会导致思维链断裂
- Add real agent demo (Tool/Skill/MCP Tool/CodeExecutor) with allow/review/deny scenarios
- Add register_rule() and custom_rules support to ToolScriptSafetyScanner
- Expand dangerous command coverage in _rules.py and _policy.py
- Add quick-start usage examples and running instructions to README
- Update tests to cover new policy fields and custom rule registration
- 问题:之前遗漏了重试这块上报,模型调用重试在trace上无显示,同时发现模型调用失败的信息不会放在对应的span里,一起修复了
Unknown language segments may contain valid non-Python input. Continue Bash scanning, but merge Python findings only when AST parsing succeeds so strict review mode does not block safe Bash scripts.

Updates #90

RELEASE NOTES: NONE
Fromsko and others added 23 commits August 10, 2026 10:59
CI test_container_cli.py uses @patch("..._container_cli.docker") which
requires the docker name to exist at module level. Call _import_docker()
at test import time to ensure the module attribute is present for patching.

Fixes 12 CI failures (9405 passed, 0 regressions).
1. Restore HAS_MAGIC as backward-compatible public alias (updated lazily
   when magic is successfully imported on non-win32)
2. Add threading.Lock to _import_docker() for concurrent safety
3. Remove dead code: unused `import sys as _sys` in test method
4. All yapf + flake8 clean, 47 passed, 0 regressions
….update

Address AI review Critical: eliminate # noqa: F821 and NameError risk
by declaring docker/Container/consume_socket_output/demux_adaptor/
frames_iter as module-level None placeholders, populated by
_import_docker() via direct assignment instead of globals().update.

- Remove TYPE_CHECKING guard (placeholders serve the same purpose)
- Remove all # noqa: F821 comments
- _exec_run_with_stdin now references real module variables, not
  dynamically injected names
- Tests @patch works naturally without _import_docker() side effects
- yapf + flake8 clean, 47 passed, 0 regressions
…ests

Address latest AI review:
1. Change except ImportError to except Exception for magic import
   failure, catching OSError and other non-Import failures safely
2. Include HAS_MAGIC in test mock save/restore to prevent state leakage
3. Add exc_info=True to the debug log for better diagnostics
Address AI review Critical: if _import_docker() fails silently and docker
remains None, the except docker.errors.DockerException line would throw
AttributeError: NoneType has no attribute errors, masking the real error.
Now explicitly checks docker is not None after import and raises a clear
RuntimeError with install instructions.
…me semantics

1. _import_docker(): catch ImportError so docker stays None when SDK
   is not installed, making the `if docker is None` guard in
   _init_docker_client() actually reachable
2. _files.py: probe magic at module import time on non-win32 to set
   HAS_MAGIC immediately, preserving the original semantics where
   external code can check HAS_MAGIC right after import
1. test_container_cli.py: replace module-level _import_docker() call
   with autouse module-scoped fixture, removing import-time global side
   effects and fixing import ordering (all imports at top)
2. _files.py: add threading.Lock for magic lazy import to prevent
   concurrent race condition on _magic_module/_magic_checked state
3. Consolidate _magic_checked=True inside lock for atomic state update
…owing

Fix AI review Critical: module-level docker=None/Container=None shadowed
the TYPE_CHECKING type aliases, breaking external
`from ..._container_cli import Container`.

- Use TYPE_CHECKING guard for docker/Container type annotations (static only)
- Store runtime symbols in private _docker_mod/_docker_container_cls/
  _docker_consume_socket_output/_docker_demux_adaptor/_docker_frames_iter
- Update all runtime references to use private names
- Update test @patch targets to _docker_mod
- No public module-level names are shadowed
1. _files.py: remove module-level import magic on non-win32 entirely
   (was still triggering at import time). Now truly deferred to first
   detect_content_type() call. HAS_MAGIC defaults False, updated lazily.
2. Remove unused _has_magic() function (dead code per review)
3. _container_cli.py: remove unused _docker_container_cls
4. _container_cli.py: widen except ImportError to except Exception
   ensuring _docker_imported=True always set, preventing retry storms
Address latest AI review warnings (no Critical this round):
1. Add logger.debug(exc_info=True) for _import_docker except path
   to aid debugging when docker import fails for non-obvious reasons
2. Move import threading to standard library group at top of file
3. Remove duplicate import threading below the third-party imports
问题:使用langfuse插件上报时,用户在span上设置的attribute没有携带到最终上报数据中,导致用户无法观测自定义埋点
解决方案:langfuse上报时保留用户自定义的attribute,带langfuse前缀的原样透传,其他自定义字段收进metadata便于观测
1. invocation 初始化异常时 span 缺失 runner 业务属性且显示未知:
   - trace_runner() 的 invocation_context 改为 Optional,初始化异常时传入
     None(此时 InvocationContext 尚未构造),依赖它的 runner.name 在 None
     时跳过,其余业务属性照常写入
   - runner 初始化失败分支统一调用 trace_runner() 上报错误状态

2. call_llm 模型调用错误被记录为成功:
   - 模型异常被 retry 层转成 LlmResponse(error_code=...) 后,trace 层未识别
     error_code,导致 span 误标成功;现补充检查 llm_response.error_code

3. 外部取消(asyncio.CancelledError)时根 invocation span 仍显示成功且缺 partial:
   - CancelledError 继承 BaseException 而非 Exception,漏过 except Exception;
   现单独捕获 CancelledError,标记 span 为错误
   - 累积已流式输出的 partial 文本,防止取消时已生成内容丢失

4. GeneratorExit 时 agent_run 无部分输出:
   - 生成器关闭(aclose/break)触发的 GeneratorExit 分支现会累积并回填
     partial 流式文本到 agent_action 中,避免已输出内容丢失
问题: 部署成AGUI服务时,如果Agent产生Event带error,则会立即终止,但有的Agent并不是终止(比如GraphAgent),它会接着执行下一个Node,之前产生Event带error时,将会返回RunErrorEvent事件,导致连接被断开

解决方案: AGUI服务端,在收到Event时,不立即返回RunErrorEvent,如果服务是最后一个Event包含错误(Agent此时已经结束),则再发送RunErrorEvent
问题:LLM调用流式输出被中断(如网络中断、模型业务错误、多轮中工具调用后再次调用被中断)时,上游 agent_run 和 runner 上报的 span 状态误报为成功、output 为空,已输出到一半的文本也随之丢失,监控侧只能下钻到 call_llm 才能看到 error_code。

解决方案:错误响应不再清空已流式的文本,span 标记为失败并保留中断前的输出内容(带 [INTERRUPTED] 标记);多轮场景在已有内容后追加中断;call_llm 的 span 也回填已流式内容。
同步 main 与 r0.1 分支版本号,携带 1.1.18 已包含的修复
feature: 增加advanced memory的示例

Update .env

feature: 第一版可用advanced memory

Preserve default Runner post-turn behavior

feature: 优化session memory实现逻辑,加入清理机制

增加coordination的test脚本

feature: 增加记忆新鲜度机制

feature: 增加环境变量设置,用户可以在.env中设置模型窗口大小

feature: 为advanced_memory增加preload功能
@CongkeChen CongkeChen closed this Aug 27, 2026
@CongkeChen CongkeChen reopened this Aug 27, 2026
@CongkeChen CongkeChen closed this Aug 27, 2026
@CongkeChen CongkeChen reopened this Aug 27, 2026
@CongkeChen CongkeChen closed this Aug 27, 2026
@CongkeChen CongkeChen reopened this Aug 27, 2026
@CongkeChen CongkeChen closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants